package com.esri.core.ags;

import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MapGeometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.d;
import com.esri.core.internal.value.e;
import com.esri.core.io.EsriServiceException;
import com.esri.core.map.TimeInfo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class MapServiceInfo implements Serializable {
    private static final long serialVersionUID = 1;
    String a;
    String b;
    String c;
    String d;
    List<LayerServiceInfo> e;
    List<Table> f;
    SpatialReference g;
    boolean h;
    TileInfo i;
    Envelope j;
    SpatialReference k;
    MapGeometry l;
    String m;
    String n;
    String o;
    MapServiceCapabilities p;
    int q;
    boolean r;
    TimeInfo s;
    double t = Double.NaN;
    double u = Double.NaN;
    boolean v = false;
    boolean w = false;
    int x = 0;

    MapServiceInfo(String str) {
        this.o = str;
    }

    public String getServiceDescription() {
        return this.a;
    }

    public String getMapName() {
        return this.b;
    }

    public String getDescription() {
        return this.c;
    }

    public String getCopyrightText() {
        return this.d;
    }

    public LayerServiceInfo[] getMapServiceLayerInfos() {
        List<LayerServiceInfo> list = this.e;
        if (list == null) {
            return null;
        }
        return (LayerServiceInfo[]) list.toArray(new LayerServiceInfo[0]);
    }

    public Table[] getTables() {
        List<Table> list = this.f;
        if (list == null) {
            return null;
        }
        return (Table[]) list.toArray(new Table[0]);
    }

    public SpatialReference getSpatialReference() {
        if (this.g == null && this.i != null && this.o.toLowerCase().endsWith("imageserver")) {
            return this.i.getSpatialReference();
        }
        return this.g;
    }

    public boolean isSingleFusedMapCache() {
        return this.h;
    }

    public TileInfo getTileInfo() {
        return this.i;
    }

    public Envelope getInitialExtent() {
        Envelope envelope = this.j;
        if (envelope == null || envelope.isEmpty()) {
            return envelope;
        }
        SpatialReference spatialReference = this.g;
        if (spatialReference == null) {
            return (this.l.getSpatialReference() == null || this.k == null || d.a(this.l.getSpatialReference(), this.k)) ? envelope : (Envelope) GeometryEngine.project(this.j, this.k, this.l.getSpatialReference());
        }
        SpatialReference spatialReference2 = this.k;
        return (spatialReference2 == null || d.a(spatialReference, spatialReference2)) ? envelope : (Envelope) GeometryEngine.project(this.j, this.k, this.g);
    }

    public Envelope getFullExtent() {
        MapGeometry mapGeometry = this.l;
        if (mapGeometry == null) {
            return null;
        }
        return (Envelope) mapGeometry.getGeometry();
    }

    public SpatialReference getInitialExtentSpatialReference() {
        SpatialReference spatialReference = this.k;
        return spatialReference == null ? this.g : spatialReference;
    }

    public void setInitialExtentSpatialReference(SpatialReference spatialReference) {
        this.k = spatialReference;
    }

    public String getUnits() {
        return this.m;
    }

    public String getUrl() {
        return this.o;
    }

    void a(String str) {
        this.o = str;
    }

    public String getSupportedImageFormatTypes() {
        return this.n;
    }

    public int getMaximumRecordCount() {
        return this.q;
    }

    public boolean isDynamicLayersSupported() {
        return this.r;
    }

    public boolean isExportTilesAllowed() {
        return this.w;
    }

    public int getMaxExportTilesCount() {
        return this.x;
    }

    public TimeInfo getTimeInfo() {
        return this.s;
    }

    public double getMinScale() {
        return this.t;
    }

    public double getMaxScale() {
        return this.u;
    }

    public boolean hasVersionedData() {
        return this.v;
    }

    public void setHasVersionedData(boolean z) {
        this.v = z;
    }

    public static MapServiceInfo fromJson(JsonParser jsonParser, String str) throws Exception {
        if (d.c(jsonParser)) {
            MapServiceInfo mapServiceInfo = new MapServiceInfo(str);
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("serviceDescription".equals(currentName)) {
                    mapServiceInfo.a = jsonParser.getText();
                } else if ("mapName".equals(currentName)) {
                    mapServiceInfo.b = jsonParser.getText();
                } else if ("description".equals(currentName)) {
                    mapServiceInfo.c = jsonParser.getText();
                } else if ("copyrightText".equals(currentName)) {
                    mapServiceInfo.d = jsonParser.getText();
                } else if ("spatialReference".equals(currentName)) {
                    mapServiceInfo.g = SpatialReference.fromJson(jsonParser);
                } else if ("singleFusedMapCache".equals(currentName)) {
                    mapServiceInfo.h = jsonParser.getBooleanValue();
                } else if ("units".equals(currentName)) {
                    mapServiceInfo.m = jsonParser.getText();
                } else if ("exportTilesAllowed".equals(currentName)) {
                    mapServiceInfo.w = jsonParser.getBooleanValue();
                } else if ("supportedImageFormatTypes".equals(currentName)) {
                    mapServiceInfo.n = jsonParser.getText();
                } else if ("fullExtent".equals(currentName)) {
                    mapServiceInfo.l = d.e(jsonParser);
                } else if ("initialExtent".equals(currentName)) {
                    MapGeometry e = d.e(jsonParser);
                    if (e != null) {
                        mapServiceInfo.j = (Envelope) e.getGeometry();
                        mapServiceInfo.k = e.getSpatialReference();
                    }
                } else if ("layers".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        mapServiceInfo.e = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            mapServiceInfo.e.add(LayerServiceInfo.fromJson(jsonParser));
                        }
                    }
                } else if ("tables".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        mapServiceInfo.f = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            mapServiceInfo.f.add(Table.fromJson(jsonParser));
                        }
                    }
                } else if ("tileInfo".equals(currentName)) {
                    mapServiceInfo.i = TileInfo.fromJson(jsonParser);
                } else if ("capabilities".equals(currentName)) {
                    mapServiceInfo.p = new MapServiceCapabilities(jsonParser.getText());
                } else if ("maxRecordCount".equals(currentName)) {
                    mapServiceInfo.q = jsonParser.getIntValue();
                } else if ("maxExportTilesCount".equals(currentName)) {
                    mapServiceInfo.x = jsonParser.getIntValue();
                } else if ("supportsDynamicLayers".equals(currentName)) {
                    mapServiceInfo.r = jsonParser.getBooleanValue();
                } else if ("timeInfo".equals(currentName)) {
                    mapServiceInfo.s = TimeInfo.fromJson(jsonParser);
                } else if ("minScale".equals(currentName)) {
                    if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) {
                        mapServiceInfo.t = jsonParser.getDoubleValue();
                    }
                } else if ("maxScale".equals(currentName)) {
                    if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) {
                        mapServiceInfo.u = jsonParser.getDoubleValue();
                    }
                } else if ("hasVersionedData".equals(currentName)) {
                    mapServiceInfo.v = jsonParser.getBooleanValue();
                } else if ("error".equals(currentName)) {
                    e a = e.a(jsonParser);
                    throw new EsriServiceException(a.a(), a.c());
                } else {
                    jsonParser.skipChildren();
                }
            }
            return mapServiceInfo;
        }
        return null;
    }

    public String toString() {
        return "MapServer [serviceDescription=" + this.a + ", mapName=" + this.b + ", description=" + this.c + ", copyrightText=" + this.d + ", layers=" + Arrays.toString(getMapServiceLayerInfos()) + ", tables=" + Arrays.toString(getTables()) + ", spatialReference=" + this.g + ", singleFusedMapCache=" + this.h + ", tileInfo=" + this.i + ", initialExtent=" + this.j + ", fullExtent=" + this.l + ", units=" + this.m + ", supportedImageFormatTypes=" + this.n + ", timeInfo=" + this.s + ",exportTilesAllowed=" + this.w + ",maxExportTilesCount=" + this.x + "]";
    }

    public int hashCode() {
        String str = this.d;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        String str2 = this.c;
        int hashCode2 = (hashCode + (str2 == null ? 0 : str2.hashCode())) * 31;
        MapGeometry mapGeometry = this.l;
        int hashCode3 = (hashCode2 + (mapGeometry == null ? 0 : mapGeometry.hashCode())) * 31;
        Envelope envelope = this.j;
        int hashCode4 = (hashCode3 + (envelope == null ? 0 : envelope.hashCode())) * 31;
        List<LayerServiceInfo> list = this.e;
        int hashCode5 = (hashCode4 + (list == null ? 0 : list.hashCode())) * 31;
        String str3 = this.b;
        int hashCode6 = (hashCode5 + (str3 == null ? 0 : str3.hashCode())) * 31;
        String str4 = this.a;
        int hashCode7 = (((hashCode6 + (str4 == null ? 0 : str4.hashCode())) * 31) + (this.h ? 1231 : 1237)) * 31;
        SpatialReference spatialReference = this.g;
        int hashCode8 = (hashCode7 + (spatialReference == null ? 0 : spatialReference.hashCode())) * 31;
        String str5 = this.n;
        int hashCode9 = (hashCode8 + (str5 == null ? 0 : str5.hashCode())) * 31;
        List<Table> list2 = this.f;
        int hashCode10 = (hashCode9 + (list2 == null ? 0 : list2.hashCode())) * 31;
        TileInfo tileInfo = this.i;
        int hashCode11 = (hashCode10 + (tileInfo == null ? 0 : tileInfo.hashCode())) * 31;
        String str6 = this.m;
        int hashCode12 = (hashCode11 + (str6 == null ? 0 : str6.hashCode())) * 31;
        String str7 = this.o;
        int hashCode13 = (hashCode12 + (str7 == null ? 0 : str7.hashCode())) * 31;
        TimeInfo timeInfo = this.s;
        return hashCode13 + (timeInfo != null ? timeInfo.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            MapServiceInfo mapServiceInfo = (MapServiceInfo) obj;
            String str = this.d;
            if (str == null) {
                if (mapServiceInfo.d != null) {
                    return false;
                }
            } else if (!str.equals(mapServiceInfo.d)) {
                return false;
            }
            String str2 = this.c;
            if (str2 == null) {
                if (mapServiceInfo.c != null) {
                    return false;
                }
            } else if (!str2.equals(mapServiceInfo.c)) {
                return false;
            }
            MapGeometry mapGeometry = this.l;
            if (mapGeometry == null) {
                if (mapServiceInfo.l != null) {
                    return false;
                }
            } else if (!mapGeometry.equals(mapServiceInfo.l)) {
                return false;
            }
            Envelope envelope = this.j;
            if (envelope == null) {
                if (mapServiceInfo.j != null) {
                    return false;
                }
            } else if (!envelope.equals(mapServiceInfo.j)) {
                return false;
            }
            List<LayerServiceInfo> list = this.e;
            if (list == null) {
                if (mapServiceInfo.e != null) {
                    return false;
                }
            } else if (!list.equals(mapServiceInfo.e)) {
                return false;
            }
            String str3 = this.b;
            if (str3 == null) {
                if (mapServiceInfo.b != null) {
                    return false;
                }
            } else if (!str3.equals(mapServiceInfo.b)) {
                return false;
            }
            String str4 = this.a;
            if (str4 == null) {
                if (mapServiceInfo.a != null) {
                    return false;
                }
            } else if (!str4.equals(mapServiceInfo.a)) {
                return false;
            }
            if (this.h != mapServiceInfo.h) {
                return false;
            }
            SpatialReference spatialReference = this.g;
            if (spatialReference == null) {
                if (mapServiceInfo.g != null) {
                    return false;
                }
            } else if (!spatialReference.equals(mapServiceInfo.g)) {
                return false;
            }
            String str5 = this.n;
            if (str5 == null) {
                if (mapServiceInfo.n != null) {
                    return false;
                }
            } else if (!str5.equals(mapServiceInfo.n)) {
                return false;
            }
            List<Table> list2 = this.f;
            if (list2 == null) {
                if (mapServiceInfo.f != null) {
                    return false;
                }
            } else if (!list2.equals(mapServiceInfo.f)) {
                return false;
            }
            TileInfo tileInfo = this.i;
            if (tileInfo == null) {
                if (mapServiceInfo.i != null) {
                    return false;
                }
            } else if (!tileInfo.equals(mapServiceInfo.i)) {
                return false;
            }
            String str6 = this.m;
            if (str6 == null) {
                if (mapServiceInfo.m != null) {
                    return false;
                }
            } else if (!str6.equals(mapServiceInfo.m)) {
                return false;
            }
            String str7 = this.o;
            if (str7 == null) {
                if (mapServiceInfo.o != null) {
                    return false;
                }
            } else if (!str7.equals(mapServiceInfo.o)) {
                return false;
            }
            TimeInfo timeInfo = this.s;
            if (timeInfo == null) {
                if (mapServiceInfo.s != null) {
                    return false;
                }
            } else if (!timeInfo.equals(mapServiceInfo.o) || this.w != mapServiceInfo.w || this.x != mapServiceInfo.x) {
                return false;
            }
            return true;
        }
        return false;
    }

    public MapServiceCapabilities getCapabilities() {
        return this.p;
    }
}
